package spring.testdemo;

import spring.User;
import spring.bean.Emp;
import spring.service.Service;
import org.junit.Test;
import org.springframework.beans.factory.BeanFactory;
import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;

/**
 * @author durant
 * @create 2021-10-29 8:49
 */
public class Testspring5 {
    @Test
    public void test1(){
        BeanFactory context=new ClassPathXmlApplicationContext("bean1.xml");
        User user = context.getBean("user", User.class);
        System.out.println(user.getAddress());
        System.out.println(user.getAge());
        System.out.println(user.getName());

    }
    @Test
    public void test2(){
        ApplicationContext context=new ClassPathXmlApplicationContext("bean1.xml");
        Service userService = context.getBean("userService",Service.class);
        userService.add();

    }
    @Test
    public void test3(){
        ApplicationContext context=new ClassPathXmlApplicationContext("bean2.xml");
        Emp emp = context.getBean("emp",Emp.class);
        emp.add();

    }

}
